package process_demo.review.about_lock;

/**
 * @author haomin
 * @date 2022/09/09 22:18
 **/
public class Main {
    static Object o = new Object();
    static class MyThread1 extends Thread{
        @Override
        public void run() {
            synchronized(o) {
                for (int i = 0; i < 100000; i++) {
                    System.out.println("张三");
                }
            }
        }
    }
    static class MyThread2 extends Thread{
        @Override
        public void run() {
            synchronized(o) {
                for (int i = 0; i < 100000; i++) {
                    System.out.println("李四");
                }
            }
        }
    }

    public static void main(String[] args) {
        MyThread1 t1 = new MyThread1();
        MyThread2 t2 = new MyThread2();
        t1.start();
        t2.start();

    }
}